<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
 
	<ui:define name="sidebar">
	<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">
	<h:form>
	<p:growl/>
	<h:outputText value="View Project" styleClass="outputTextTitle"/>		
      <p:panel header="View Registered Projects">   
         <h:panelGrid style="width: 100%;"> 
            <p:dataTable  tableStyle="width:100%" id="projects" value="#{projectViewBean.projects}" var="project"
						paginator="true" rows="15">  
  
			        <p:column headerText="S.No">
						<h:outputText value="#{project.sNo}" />
			        </p:column>
			        <p:column headerText="Project Name">
							<h:outputText value="#{project.projectName}" />
				    </p:column>
			        <p:column headerText="Client Name">
						<h:outputText value="#{project.client}" />
					</p:column>
					<p:column headerText="Created By">
						<h:outputText value="#{project.projectCreatedBy}" />
					</p:column>
					<p:column headerText="Create Date">
						<h:outputText value="#{project.createDate}" >
							<f:convertDateTime pattern="dd-MM-yyyy"/>
						</h:outputText>
					</p:column>
					<p:column headerText="No.of Resources">
						<h:outputText value="#{project.noOfResourecs}" />
					</p:column>
					<p:column headerText="Strat Date">
						<h:outputText value="#{project.periodFrom}" >
							<f:convertDateTime pattern="dd-MM-yyyy"/>
						</h:outputText>
					</p:column>
					<p:column headerText="End Date">
						<h:outputText value="#{project.periodTo}" >
							<f:convertDateTime pattern="dd-MM-yyyy"/>
						</h:outputText>
					</p:column>
					<p:column headerText="View">
						 <p:commandButton value="View" oncomplete="projectViewDialog.show()" update="@form" process="@this" 
							actionListener="#{projectViewBean.viewActionListener}" >
							 <f:param  name="projectId" value="#{project.projectId}" />							 
						 </p:commandButton> 
					</p:column>
					<p:column headerText="Update/Delete" rendered="#{projectViewBean.viewForAcRole eq 'AC'}"> 
						 <p:commandButton value="Update/Delete" oncomplete="projectEditDialog.show()" update="@form" process="@this" 
							actionListener="#{projectViewBean.viewOrEditActionListener}" >
							 <f:param id="projectId" name="projectId" value="#{project.projectId}" />							 
						 </p:commandButton>
					</p:column>		       
		    </p:dataTable>
		</h:panelGrid>
	</p:panel>
	
	<!-- Edit Dialog -->
			<p:dialog hideEffect="fade" showEffect="fade"
				header="View/Edit Project : #{projectViewBean.selectedProject.projectName} "
				id="projectEditDialog" widgetVar="projectEditDialog" resizable="false"
				modal="true">
				<h:panelGrid columns="4" cellpadding="10"
					style="border: 1px solid #d9d9d9; width: 100%">
			   
			    <h:outputLabel value="" style="color : red;"/>
				<h:outputLabel value="Created On"/>
				<h:outputLabel value=" : " />
				<h:outputText  value="#{projectViewBean.selectedProject.createDate}">
					<f:convertDateTime pattern="dd-MM-yyyy"/>
				</h:outputText>
			   
			    <h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['projectname.label']}"/>
				<h:outputLabel value=" : " />
				<p:inputText  value="#{projectViewBean.selectedProject.projectName}"/>

				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['ownerofproject.label']}"/>
				<h:outputLabel value=" : " />
				<p:selectOneMenu value="#{createProjectBean.selectedPMId}" style="width:140px;">						
						<f:selectItems value="#{createProjectBean.ownerOfProjectMap}" /> 
				</p:selectOneMenu>
				
				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['clientname.label']}"/>
				<h:outputLabel value=" : " />
				<p:inputText value="#{projectViewBean.selectedProject.client}" />

				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['clientlocation.label']}"/>
				<h:outputLabel value=" : " />
				<p:inputText value="#{projectViewBean.selectedProject.clientLocation}"/>
				
				<h:outputLabel value="" style="color : red;"/>
				<h:outputLabel value="#{msg['endclient.label']}"/>
				<h:outputLabel value=" : " />
				<p:inputText value="#{projectViewBean.selectedProject.endClint}" />

				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['clientcontactperson.label']}"/>
				<h:outputLabel value=" : " />
				<p:inputText value="#{projectViewBean.selectedProject.contactPerson}" /> 
				
				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['clientcontactnum.label']}"/>
				<h:outputLabel value=" : " />
				<p:inputText value="#{projectViewBean.selectedProject.contactNumber}" />

				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['clientaddress.label']}"/>
				<h:outputLabel value=" : " />
				<p:inputTextarea value="#{projectViewBean.selectedProject.clientAddress}" />
				
				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['projectstratdate.label']}"/>
				<h:outputLabel value=" : " />
				<p:calendar value="#{projectViewBean.selectedProject.periodFrom}" pattern="dd-MM-yyyy"/>

				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['projectenddate.label']}"/>
				<h:outputLabel value=" : " />
				<p:calendar  value="#{projectViewBean.selectedProject.periodTo}" pattern="dd-MM-yyyy"/>
				
				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['noofresources.label']}"/>
				<h:outputLabel value=" : " />
				<p:inputText  value="#{projectViewBean.selectedProject.noOfResourecs}" />

				<h:outputLabel value="*" style="color : red;"/>
				<h:outputLabel value="#{msg['createdby.label']}"/>
				<h:outputLabel value=" : " />
				<p:inputText  value="#{projectViewBean.selectedProject.projectCreatedBy}" />	           
			     
								
				</h:panelGrid>
				
				<h:panelGroup style="float:right;">
					<p:commandButton id="updateButton" value="Update" actionListener="#{projectViewBean.updateProjectListener}"  update="@form"/>
					<p:commandButton id="deleteButton" value="Delete" actionListener="#{projectViewBean.deleteProjectListener}" update="@form"/>
				
				</h:panelGroup>					
							
				  
			</p:dialog>
			
			<!-- View Project -->
			
			<p:dialog hideEffect="fade" showEffect="fade"
				header="View Project : #{projectViewBean.selectedProject.projectName} "
				id="projectViewDialog" widgetVar="projectViewDialog" resizable="false"
				modal="true">
				<h:panelGrid columns="3" cellpadding="10" cellspacing="9"
					style="border: 1px solid #d9d9d9; width: 100%">
			   
			    
				<h:outputLabel value="Created On"/>
				<h:outputLabel value=" : " />
				<h:outputText  value="#{projectViewBean.selectedProject.createDate}">
					<f:convertDateTime pattern="dd-MM-yyyy"/>
				</h:outputText>			   
			   
				<h:outputLabel value="#{msg['projectname.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel  value="#{projectViewBean.selectedProject.projectName}"/>

				
				<h:outputLabel value="#{msg['ownerofproject.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel value="#{projectViewBean.selectedProject.owner.firstName} #{projectViewBean.selectedProject.owner.lastName}" />	
				
				<h:outputLabel value="#{msg['clientname.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel value="#{projectViewBean.selectedProject.client}" />

				<h:outputLabel value="#{msg['clientlocation.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel value="#{projectViewBean.selectedProject.clientLocation}"/>
				
				
				<h:outputLabel value="#{msg['endclient.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel value="#{projectViewBean.selectedProject.endClint}" />

				
				<h:outputLabel value="#{msg['clientcontactperson.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel value="#{projectViewBean.selectedProject.contactPerson}" /> 
				
				
				<h:outputLabel value="#{msg['clientcontactnum.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel value="#{projectViewBean.selectedProject.contactNumber}" />

				
				<h:outputLabel value="#{msg['clientaddress.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel value="#{projectViewBean.selectedProject.clientAddress}" />
				
				
				<h:outputLabel value="#{msg['projectstratdate.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputText value="#{projectViewBean.selectedProject.periodFrom}" >
					<f:convertDateTime pattern="dd-MMM-yyyy"/>
				</h:outputText>

				
				<h:outputLabel value="#{msg['projectenddate.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputText  value="#{projectViewBean.selectedProject.periodTo}">				
					<f:convertDateTime pattern="dd-MMM-yyyy"/>
				</h:outputText>
				
				
				<h:outputLabel value="#{msg['noofresources.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel  value="#{projectViewBean.selectedProject.noOfResourecs}" />

				
				<h:outputLabel value="#{msg['createdby.label']}"/>
				<h:outputLabel value=" : " />
				<h:outputLabel  value="#{projectViewBean.selectedProject.projectCreatedBy}" />	           
			     
								
				</h:panelGrid>
				
				<h:panelGroup style="float:right;">
					<p:commandButton id="close" value="Close" actionListener="#{projectViewBean.closeProjectListener}"  update="@form"/>					
				</h:panelGroup>					
							
				  
			</p:dialog>
			
		</h:form>
	</ui:define>
</ui:composition>

